<?php

namespace Blog\Model;


use Hx\Mvc\Model\Table;

class Category extends Table {

    public function __construct() {
        $this->setTable('fxh_category');
    }

    public function getRank() {
        return $this->select(array(
            'order' => 'countNum DESC,orderNum desc',
            'where' => 'type = "blog"'
        ), 'id,name,slug,countNum');
    }

    public function getBySlug($slug) {
        return $this->only(array(
            'where' => 'slug = :slug',
            'param' => array(
                'slug' => $slug
            )
        ), 'id,name,slug,desc,countNum');
    }

    public function getById($id) {
        return $this->only(array(
            'where' => 'id = :id',
            'param' => array(
                'id' => (int)$id
            )
        ), 'id,name,slug,desc,countNum');
    }
}